<template>
  <el-container>
    <el-header>
      <div class="logo-wrapper">
        <el-avatar src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"></el-avatar>
        <div class="title">
          TODO-List
        </div>
      </div>
      <el-tabs v-model="activeName" @tab-click="handleClick">
        <el-tab-pane label="添加待办事项" :name="activeList[0]"></el-tab-pane>
        <el-tab-pane label="已完成事项" :name="activeList[1]"></el-tab-pane>
        <el-tab-pane label="已删除事项" :name="activeList[2]"></el-tab-pane>
        <el-tab-pane label="所有事项" :name="activeList[3]"></el-tab-pane>
      </el-tabs>
    </el-header>
    <el-main>
      <router-view/>
    </el-main>
  </el-container>
</template>

<script lang="ts">
import useTabComposition from "@/components/TabComposition";
import {defineComponent} from "vue";

export default defineComponent({
  name: 'Home',
  setup() {
    const {activeName, activeList, handleClick} = useTabComposition()
    return {
      activeName,
      activeList,
      handleClick
    }
  }
})
</script>

<style lang="scss" scoped>
.el-container {
  width: 600px;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);

  .el-header {
    display: flex;

    .logo-wrapper {
      display: flex;
      align-items: center;
      .title {
        text-align: center;
        margin-left: 10px;
      }
    }

    .el-tabs {
      flex: 1;
      margin-left: 10px;
    }
  }
}
</style>
